<template>
<!-- 组织管理 -->
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <!-- <el-form-item label="组织名称" prop="orgName">
        <el-input
          v-model="queryParams.orgName"
          placeholder="请输入组织名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="系部" prop="unitCode">
        <el-select
          v-model="queryParams.unitCode"
          placeholder="请选择"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="(dict,index) in unitNameList"
            :key="index"
            :label="dict.sponsorName"
            :value="dict.sponsorCode"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="班级" prop="classNo">
        <el-input
          v-model="queryParams.classNo"
          placeholder="请输入班级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年级" prop="grade">
        <el-input
          v-model="queryParams.grade"
          placeholder="请输入年级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="状态" prop="status">
        <el-select
          v-model="queryParams.orgStatus"
          placeholder="请选择"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="dict in dict.type.orgStatus"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <!-- <el-button type="primary" v-hasPermi="['approval:organMan:list']" icon="el-icon-key" size="mini" @click="handleAdd(1)">新增本科生班团</el-button> -->
        <!-- <el-button type="primary" v-hasPermi="['approval:organMan:list']" icon="el-icon-key" size="mini" @click="handleAdd(5)">批量导入本科生</el-button> -->
        <!-- <el-button type="primary" v-hasPermi="['approval:organMan:addGraduate']" icon="el-icon-key" size="mini" @click="handleAdd(2)">新增研究生班团</el-button> -->
        <!-- <el-button type="primary" v-hasPermi="['approval:organMan:addGraduate']" icon="el-icon-key" size="mini" @click="handleAdd(4)">批量导入研究生</el-button> -->
        <!-- <el-button type="primary" v-hasPermi="['approval:organMan:addGraduate']" icon="el-icon-key" size="mini" @click="handleAdd(3)">同步所有研究生班团</el-button> -->
        <!-- <el-dropdown @command="handleCommand" style="margin-left: 10px;">
          <el-button
            type="primary"
            size="mini"
            v-hasPermi="['approval:organMan:export']"
          >导出任命信息<i class="el-icon-arrow-down el-icon--right"></i></el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item v-for="option in schoolYearList"
            :key="option.schoolYearId" :command="option.schoolYearId"  @click="handleExport">{{option.schoolYearId}}</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown> -->
      </el-form-item>
    </el-form>

    <el-table border v-loading="loading" :data="orgList" @selection-change="handleSelectionChange">
      <el-table-column label="组织名称" align="center" prop="orgName" />
      <el-table-column label="学院" align="center" prop="unitName" />
<!--      <el-table-column label="指导单位编码" align="center" prop="unitCode" /> -->
      <!-- <el-table-column label="班级" align="center" prop="classNo" />
      <el-table-column label="年级" align="center" prop="grade" /> -->
<!--      <el-table-column label="类型" align="center" prop="type" /> -->
      <el-table-column label="教师管理员" align="center">
        <template slot-scope="scope">
          {{scope.row.teacherName}}<br/>{{scope.row.teacherId}}
        </template>
      </el-table-column>
      <el-table-column label="学生管理员" align="center">
        <template slot-scope="scope">
          {{scope.row.studentName}}<br/>{{scope.row.studentId}}
        </template>
      </el-table-column>
    <!--  <el-table-column label="0待审核；1活跃；2不活跃" align="center" prop="orgStatus" />
      <el-table-column label="审核时间" align="center" prop="auditTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.auditTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核教师" align="center" prop="auditId" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <!-- <el-button
            style="padding: 8px;margin-right: 8px;"
            size="mini"
            type="primary"
            v-hasPermi="['organ:groupOrgan:setTeacherID']"
            @click="handleUpdateTeacher(scope.row)"
          >设置辅导员</el-button>
          <el-button
            style="padding: 8px;margin-right: 8px;"
            size="mini"
            type="primary"
            v-if="canWrite(scope.row)"
            v-hasPermi="['approval:organMan:setManager']"
            @click="handleUpdate(scope.row)"
          >设置学生管理员</el-button>-->
          <router-link style="margin-right: 8px;" :to="'/approval/organMan-data/index/'+ scope.row.orgId " class="link-type"> 
            <el-button
              style="padding: 8px;"
              size="mini"
              type="primary"
              v-hasPermi="['approval:organMan:check']"
            >查看</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加辅导员 -->
    <el-dialog title="添加辅导员" :visible.sync="teacherOpen" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="辅导员" prop="teacherId">
            <el-select
              v-model="form.teacherId"
              filterable
              remote
              reserve-keyword
              placeholder="请输入关键词"
              :remote-method="remoteMethod2"
              :loading="searchLoading">
              <el-option
                v-for="(item,index) in options"
                :key="index"
                :label="item.label"
                :value="item.label.substring(0,item.label.lastIndexOf('-'))">
              </el-option>
            </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormTeacher">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改组织信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="学生管理员" prop="studentId">
          <el-select
              v-model="form.studentId"
              filterable
              remote
              reserve-keyword
              placeholder="请输入关键词"
              :remote-method="remoteMethod"
              :loading="searchLoading">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--修改本科生班团 -->
    <el-dialog :title="title" :visible.sync="updateOpen" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="班团名称" prop="orgName">
          <el-select multiple v-model="form.orgName" placeholder="请选择">
            <el-option label="18本科生" value="18本科生" />
            <el-option label="19本科生" value="19本科生" />
            <el-option label="20本科生" value="20本科生" />
            <el-option label="21本科生" value="21本科生" />
            <el-option label="22本科生" value="22本科生" />
          </el-select>
          <!-- <el-input @change="changeValue0($event,1)" v-model="form.orgName"  placeholder="请输入内容"></el-input> -->
        </el-form-item>
        <el-form-item label="指导单位"  prop="unitCode">
          <el-select
            v-model="form.unitName"
            placeholder="请选择"
            clearable
            @change="changeValue($event,1)"
            style="width: 240px"
          >
            <el-option
              v-for="(dict,index) in unitNameList"
              :key="index"
              :label="dict.sponsorName"
              :value="dict"
            >{{dict.sponsorName}}</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="班级" prop="classNo">
          <el-input disabled v-model="form.classNo"  placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="年级" prop="grade">
          <el-input disabled v-model="form.grade"  placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="辅导员" prop="teacherId">
          <el-select
              v-model="form.teacherId"
              filterable
              remote
              reserve-keyword
              placeholder="请输入关键词"
              :remote-method="remoteMethod2"
              :loading="searchLoading">
              <el-option
                v-for="(item,index) in options"
                :key="index"
                :label="item.label"
                :value="item.label.substring(0,item.label.lastIndexOf('-'))">
              </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="团支部书记" prop="studentId">
          <el-select
              v-model="form.studentId"
              filterable
              remote
              reserve-keyword
              placeholder="请输入关键词"
              :remote-method="remoteMethod"
              :loading="searchLoading">
              <el-option
                v-for="(item,index) in options"
                :key="index"
                :label="item.label"
                :value="item.label.substring(0,item.label.lastIndexOf('-'))">
              </el-option>
            </el-select>
        </el-form-item>
        
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormUpdateDetail">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--添加研究生 -->
    <el-dialog :title="title" :visible.sync="updateOpen2" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="班团名称" prop="orgName">
          <el-select @change="changeValue0($event,2)" v-model="form.orgName" placeholder="请选择">
            <el-option label="18研究生" value="18研究生" />
            <el-option label="19研究生" value="19研究生" />
            <el-option label="20研究生" value="20研究生" />
            <el-option label="21研究生" value="21研究生" />
            <el-option label="22研究生" value="22研究生" />
          </el-select>
          <!-- <el-input v-model="form.orgName"  placeholder="请输入内容"></el-input> -->
        </el-form-item>
        <el-form-item label="指导单位"  prop="unitCode">
          <el-select
            v-model="form.unitName"
            placeholder="请选择"
            @change="changeValue($event,2)"
            style="width: 240px"
          >
            <el-option
              v-for="(dict,index) in unitNameList"
              :key="index"
              :label="dict.sponsorName"
              :value="dict"
            >{{dict.sponsorName}}</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="班级" prop="classNo">
          <el-input v-model="form.classNo" :disabled="true" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="年级" prop="grade">
          <el-input v-model="form.grade" :disabled="true" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="辅导员">
          <el-select
              v-model="form.teacherId"
              filterable
              remote
              reserve-keyword
              placeholder="请输入关键词"
              :remote-method="remoteMethod2"
              :loading="searchLoading">
              <el-option
                v-for="(item,index) in options"
                :key="index"
                :label="item.label"
                :value="item.label.substring(0,item.label.lastIndexOf('-'))">
              </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="团支部书记" prop="studentId">
          <el-select
              v-model="form.studentId"
              filterable
              remote
              reserve-keyword
              placeholder="请输入关键词"
              :remote-method="remoteMethod"
              :loading="searchLoading">
              <el-option
                v-for="(item,index) in options"
                :key="index"
                :label="item.label"
                :value="item.label.substring(0,item.label.lastIndexOf('-'))">
              </el-option>
            </el-select>
        </el-form-item>
        
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormUpdateDetail2">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--批量添加研究生 -->
    <el-dialog :title="title" :visible.sync="updateOpen4" width="500px" append-to-body>
      <el-form ref="form" :model="form4" :rules="rules" label-width="100px">
        <el-form-item label="班团名称" prop="orgName">
          <el-select multiple v-model="form4.orgName" placeholder="请选择">
            <el-option label="18研究生" value="18研究生" />
            <el-option label="19研究生" value="19研究生" />
            <el-option label="20研究生" value="20研究生" />
            <el-option label="21研究生" value="21研究生" />
            <el-option label="22研究生" value="22研究生" />
          </el-select>
          <!-- <el-input v-model="form.orgName"  placeholder="请输入内容"></el-input> -->
        </el-form-item>
        <el-form-item label="指导单位"  prop="unitName">
          <el-select
            @change="changeUnitName"
            multiple 
            v-model="form4.unitName"
            placeholder="请选择"
            style="width: 240px"
          >
            <el-option
              v-for="(dict,index) in unitNameList"
              :key="index"
              :label="dict.sponsorName"
              :value="dict.sponsorName"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :disabled="loading" type="primary" @click="submitFormUpdateDetail4">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--批量添加本科生 -->
    <el-dialog :title="title" :visible.sync="updateOpen5" width="500px" append-to-body>
      <el-form ref="form" :model="form5" :rules="rules" label-width="100px">
        <el-form-item label="班团名称" prop="orgName">
          <el-select multiple v-model="form5.orgName" placeholder="请选择">
            <el-option label="18本科生" value="18本科生" />
            <el-option label="19本科生" value="19本科生" />
            <el-option label="20本科生" value="20本科生" />
            <el-option label="21本科生" value="21本科生" />
            <el-option label="22本科生" value="22本科生" />
          </el-select>
          <!-- <el-input v-model="form.orgName"  placeholder="请输入内容"></el-input> -->
        </el-form-item>
        <el-form-item label="指导单位"  prop="unitName">
          <el-select
            @change="changeUnitName"
            multiple 
            v-model="form5.unitName"
            placeholder="请选择"
            style="width: 240px"
          >
            <el-option
              v-for="(dict,index) in unitNameList"
              :key="index"
              :label="dict.sponsorName"
              :value="dict.sponsorName"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :disabled="loading" type="primary" @click="submitFormUpdateDetail5">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listOrg, getOrg, delOrg, addOrg, addGraduate,batchAddGraduate,batchAddUnderGraduate,addGraduateAll,updateOrg,getstudentmanager,getTeacherManager,setstudentmanager,setteachermanager } from "@/api/organ/classOrgan";
import { listSponsor } from "@/api/system/sponsor";
import { mapGetters } from 'vuex';
import {GetYearList} from '@/api/organ/organ';
export default {
  name: "Org",
  dicts: ['sys_normal_disable', 'orgStatus'],
  computed: {
    ...mapGetters(['roles', 'name']),
  },
  data() {
    return {
      schoolYearList: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 组织信息表格数据
      orgList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orgName: null,
        unitName: null,
        unitCode: null,
        classNo: null,
        grade: null,
        type: 5,
        teacherId: null,
        studentId: null,
        orgStatus: null,
        auditTime: null,
        auditId: null
      },
      // 表单参数
      form: {},
      form4: {},
      form5: {},
      // 表单校验
      rules: {
        orgName: [{ required: true, message: '班团名称不能为空', trigger: 'blur' }],
        unitCode: [{ required: true, message: '指导单位不能为空', trigger: 'blur' }],
        classNo: [{ required: true, message: '班级不能为空', trigger: 'blur' }],
        grade: [{ required: true, message: '年级不能为空', trigger: 'blur' }],
        // teacherId: [{ required: true, message: '辅导员不能为空', trigger: 'blur' }],
        // studentId: [{ required: true, message: '团支部书记不能为空', trigger: 'blur' }],
      },
      updateOpen:false,
      updateOpen2:false,
      updateOpen4:false,
      updateOpen5:false,
      options: [],
      value: [],
      list: [],
      searchLoading: false,
      unitNameList:[],
      orgForm:{},
      unitNameArr:[],

      teacherOpen:false,
    };
  },
  created() {
    GetYearList().then(response => { 
      console.log(response, 'Years');
      this.schoolYearList = response.rows;
      for (let i  = 0; i  < response.total; i ++) {
        if(response.rows[i].defaultValue == "1"){
          // this.queryParams.schoolYear = response.rows[i].schoolYearId;
        }
      }
    });
     /** 学院下拉框 */
    listSponsor().then(response => {
      this.unitNameList = response.rows;
    });
    this.getList();

  },
  methods: {
    /** 查询组织信息列表 */
    getList() {
      this.loading = true;
      listOrg(this.queryParams).then(response => {
        this.orgList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 判断是否能设置学生
    canWrite(row) {
      console.log(row);
      var isCanWrite = false;
      if (this.roles) {
        console.log(this.roles, 'roles');
        for (let i = 0; i < this.roles.length; i++) {
          if (
            this.roles[i] == 'student-school' ||
            this.roles[i] == 'common' ||
            this.roles[i] == 'admin'
          ) {
            isCanWrite = true;
            break;
          }
          if (this.roles[i] == 'teacher1') {
            if (this.name == row.teacherId) {
              isCanWrite = true;
              break;
            }
          }
        }
      }
      console.log(isCanWrite, 'isCanWrite');
      return isCanWrite;
    },
    changeUnitName(item){
      console.log(item,"item")
      // this.form.unitName = this.form.unitName + item.unitName;
      // this.form.unitCode = this.form.unitCode + '' + item.unitCode;
    },
    // 研究生选班团
    changeValue0(event,type){
      console.log(event,"va00000")
      var gradeVal = event.substring(0,2);
      this.form.grade = "20" + gradeVal;
      if(this.form.unitCode){
        if(type==1){
          // this.form.classNo = event.substring(0,8);
        }else{
          this.form.classNo = gradeVal + gradeVal + this.form.unitCode +'';
        }
      }
    },
    // 指导单位赋值
    changeValue(event,type){
      console.log(event,"valllll")
      this.form.unitCode=event.sponsorCode
      this.form.unitName=event.sponsorName
      if(this.form.orgName){
        if(type==1){
          // this.form.classNo = this.form.orgName.substring(0,8);
        }else{
        var gradeVal = this.form.orgName.substring(0,2);
        this.form.classNo = gradeVal + gradeVal + this.form.unitCode +'';
        }
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.updateOpen = false;
      this.updateOpen2 = false;
      this.updateOpen4 = false;
      this.updateOpen5 = false;
      this.teacherOpen = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        orgId: null,
        orgName: null,
        unitName: null,
        unitCode: null,
        classNo: null,
        grade: null,
        type: 5,
        teacherId: null,
        studentId: null,
        orgStatus: "0",
        createTime: null,
        updateTime: null,
        auditTime: null,
        auditId: null
      };
      this.form4 = this.form;
      this.form5 = this.form;
      // this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orgId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd(num) {
      this.reset();
      if(num==1){
        this.updateOpen = true;
        this.title = "添加本科生班团";
      }else if(num==2){
        this.updateOpen2 = true;
        this.title = "添加研究生班团";
      }else if(num==4){
        this.updateOpen4 = true;
        this.title = "批量导入研究生";
      }else if(num==5){
        this.updateOpen5 = true;
        this.title = "批量导入本科生";
      }else{
        addGraduateAll().then(response => {
              if(response.code==200){
              this.$modal.msgSuccess("同步成功");
              this.updateOpen = false;
              this.getList();
              }
            });
      }
    },
    // 添加班团确认
    submitFormUpdateDetail(){
      this.$refs["form"].validate(valid => {
        if (valid) {
            addOrg(this.form).then(response => {
              if(response.code==200){
              this.$modal.msgSuccess("添加成功");
              this.updateOpen = false;
              this.getList();
              }
            });
        }
      });
    },
    // 添加研究生班团确认
    submitFormUpdateDetail2(){
      this.$refs["form"].validate(valid => {
        if (valid) {
            addGraduate(this.form).then(response => {
              if(response.code==200){
              this.$modal.msgSuccess("添加成功");
              this.updateOpen2 = false;
              this.getList();
              }
            });
        }
      });
    },
    // 批量导入研究生
    submitFormUpdateDetail4(){
      this.loading = true;
      var form = {}
      form.orgName = this.form4.orgName.toString();
      form.unitName = this.form4.unitName.toString();
      this.$refs["form"].validate(valid => {
        if (valid) {
            batchAddGraduate(form).then(response => {
              if(response.code==200){
              this.$modal.msgSuccess("添加成功");
              this.loading = false;
              this.updateOpen4 = false;
              this.getList();
              }
            });
        }
      });
    },
    // 批量导入研究生
    submitFormUpdateDetail5(){
      this.loading = true;
      var form = {}
      form.orgName = this.form5.orgName.toString();
      form.unitName = this.form5.unitName.toString();
      this.$refs["form"].validate(valid => {
        if (valid) {
            batchAddUnderGraduate(form).then(response => {
              if(response.code==200){
              this.$modal.msgSuccess("添加成功");
              this.loading = false;
              this.updateOpen5 = false;
              this.getList();
              }
            });
        }
      });
    },
    /** 设置管理员操作 */
    handleUpdate(row) {
      this.reset();
      this.form.orgId=row.orgId;
      this.open = true;
      this.title = "设置管理员";
      /* const orgId = row.orgId; || this.ids
      getOrg(orgId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改组织信息";
      }); */
    },
    /** 设置老师管理员操作 */
    handleUpdateTeacher(row) {
      this.reset();
      this.form.orgId=row.orgId;
      this.teacherOpen = true;
      this.title = "设置辅导员";
    },
    /** 设置辅导员 */
    submitFormTeacher() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.orgId != null) {
            setteachermanager(this.form).then(response => {
              if(response.code==200){
              this.$modal.msgSuccess("设置成功");
              this.teacherOpen = false;
              this.getList();
              }
            });
          }else{

          }
        }
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.orgId != null) {
            setstudentmanager(this.form).then(response => {
              if(response.code==200){
                this.$modal.msgSuccess("设置成功");
                this.open = false;
                this.getList();
              }
            });
          }else{

          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orgIds = row.orgId || this.ids;
      this.$modal.confirm('是否确认删除组织信息编号为"' + orgIds + '"的数据项？').then(function() {
        return delOrg(orgIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/org/export', {
        ...this.queryParams
      }, `org_${new Date().getTime()}.xlsx`)
    },
    /** 查询学生管理员 */
    remoteMethod(query) {
      if (query !== '') {
        this.loading = true;
        getstudentmanager(query).then(response => {
          this.loading = false;
          this.options = response.rows.filter(item => {
            return item.label.toLowerCase()
              .indexOf(query.toLowerCase()) > -1;
          });
        });
      } else {
        this.options = [];
      }
    },
    /** 查询教师管理员 */
    remoteMethod2(query) {
      if (query !== '') {
        this.loading = true;
        getTeacherManager(query).then(response => {
          this.loading = false;
          this.options = response.rows.filter(item => {
            return item.label.toLowerCase()
              .indexOf(query.toLowerCase()) > -1;
          });
        });
      } else {
        this.options = [];
      }
    },
    /** 导出
     */
    handleCommand(command) {
      this.queryParams.schoolYear = command;
      this.download('committee/org/export2', {
        ...this.queryParams
      }, `org_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
